package com.cc.teambuiding.controller;

import com.cc.teambuiding.entity.User;
import com.cc.teambuiding.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name = "用户管理")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    @Operation(summary = "获取所有用户")
    public List<User> listUsers() {
        return userService.listUsers();
    }

    @PostMapping("/add")
    @Operation(summary = "添加用户")
    public boolean addUser(@RequestBody User user) {
        return userService.addUser(user);
    }

    @GetMapping("/squad/{squadId}")
    @Operation(summary = "获取指定小组的所有用户")
    public List<User> getUsersBySquadId(@PathVariable Long squadId) {
        return userService.getUsersBySquadId(squadId);
    }
}
